package com.ror.util;

import javax.swing.*;

public class DialogUtil {
    public static void show(String dialogText) {
        show(dialogText, 250, 150);
    }

    public static void show(String dialogText, int width, int height) {
        JDialog aboutJDialog = new JDialog();
        JLabel dialogJLabel = new JLabel(dialogText);
        dialogJLabel.setHorizontalAlignment(SwingConstants.CENTER);

        aboutJDialog.setSize(width, height);
        aboutJDialog.setAlwaysOnTop(true);
        //设置弹窗居中
        aboutJDialog.setLocationRelativeTo(null);
        //设置弹窗不关闭无法聚焦下面的界面，关闭后自动聚焦
        aboutJDialog.setModal(true);
        aboutJDialog.getContentPane().add(dialogJLabel);
        aboutJDialog.setVisible(true);
    }
}
